package cn.jzq.kotoba.modules.designpattern.strategy;

/**
 * @author jzq
 * @date 2019/2/12 12:58
 */
public abstract class Duck {

    private FlyBehavior flyBehavior;

    private QuackBehavior quackBehavior;

    abstract void display();

    /**
     * 将飞行的行为委托给飞行的行为类
     */
    public void doFly(){
        flyBehavior.fly();
    }

    public void doQuack() {
        quackBehavior.quack();
    }

    public void setFlyBehavior(FlyBehavior flyBehavior) {
        this.flyBehavior = flyBehavior;
    }

    public void setQuackBehavior(QuackBehavior quackBehavior) {
        this.quackBehavior = quackBehavior;
    }
}
